/*
 *   Copyright (c) 2010-2022, SIUFUNG
 */
package net.siufung.market.base.tenant.controller.model.dto;

import com.google.common.collect.Lists;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.extern.slf4j.Slf4j;
import net.siufung.core.model.AbstractDto;
import net.siufung.market.base.tenant.mapper.entity.TenantMenu;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * <p>
 * 系统菜单租户表 新增数据传参对象
 * </p>
 * @author 陈建峰
 * @since 2022-07-06 14:45:08
 */
@Slf4j
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="TenantMenuSaveDto", description="系统菜单租户表新增数据传参对象")
public class TenantMenuSaveDto extends AbstractDto {


    private static final long serialVersionUID = -623833951154670178L;

    /**
     * 菜单id
     */
    @ApiModelProperty(value = "菜单id")
    @NotEmpty(message = "菜单列表不能为空！")
    private Integer[] menuIdList;

    /**
     * 租户id
     */
    @ApiModelProperty(value = "租户id")
    @NotNull(message = "租户Id不能为空！")
    private Integer tenantId;


    /**
     * TenantMenu 转化成 TenantMenuSaveDto 数据领域实体
     * @return TenantMenu
     */
    public List<TenantMenu> toList(){
        TenantMenu tenantMenu;
        List<TenantMenu> tenantMenuList = Lists.newArrayList();
        for (Integer menuId: menuIdList){
            tenantMenu = new TenantMenu();
            tenantMenu.setTenantId(tenantId);
            tenantMenu.setMenuId(menuId);
            tenantMenuList.add(tenantMenu);
        }
        return tenantMenuList;
    }
}